package ufcg.edu.br.projetoles.gui;

import java.util.Date;

import ufcg.edu.br.projetoles.source.Tarefa;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.example.projetopilotoles.R;

public class TelaInicial extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tela_inicial);
		
		Button bntSalvar = (Button) findViewById(R.id.button1);
		Button bntRecuperar = (Button) findViewById(R.id.button2);
		final EditText text = (EditText) findViewById(R.id.editText1);
		
		final Tarefa t = new Tarefa(this, "estudar", "urgente", new Date(), Tarefa.prioridades.ALTA.getPrioridade());
		
		bntSalvar.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				t.save();
			}
		});
		
		bntRecuperar.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Tarefa t2 = Tarefa.findById(Tarefa.class, (long) 1);
				text.setText(t2.getTarefa());
				
			}
		});
		
	}
	


	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.tela_inicial, menu);
		return true;
	}

}
